package com.jk.mindskip.hystrix;

import com.jk.mindskip.dto.TbAdmin;
import com.jk.mindskip.pojo.PagedResponse;
import com.jk.mindskip.service.TbAdminServiceFeign;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @description:熔断器
 * @author: wsy
 * @date: 2024/12/10 上午10:32
 * @param:
 * @return:
 **/
@Component
@Slf4j
public class TbAdminServiceFeignHystrix implements FallbackFactory<TbAdminServiceFeign> {
    @Override
    public TbAdminServiceFeign create(Throwable throwable) {
        return new TbAdminServiceFeign() {
            @Override
            public PagedResponse<TbAdmin> findAdminList(TbAdmin admin, Integer pageNum, Integer pageSize) {
                log.debug("TbAdminServiceFeign接口下的findAdminList方法：用户列表分页查询服务远程接口熔断：{}，", throwable.toString(), throwable);
                return null;
            }

            @Override
            public void addAdmin(TbAdmin admin) {
                log.debug("TbAdminServiceFeign接口下的addAdmin方法：用户新增服务远程接口熔断：{}，", throwable.toString(), throwable);
            }

            @Override
            public TbAdmin findTbAdminByUserName(String username) {
                log.debug("TbAdminServiceFeign接口下的findTbAdminByUserName方法：通过用户名获得用户信息服务远程接口熔断：{}，", throwable.toString(), throwable);
                return null;
            }

            @Override
            public List<String> selectPermsByUserId(Integer id) {
                log.debug("TbAdminServiceFeign接口下的selectPermsByUserId方法：通过用户id获得权限集合服务远程接口熔断：{}，", throwable.toString(), throwable);
                return null;
            }
        };
    }
}
